<?php
class Request {
	private $get = array();
	private $cookie = array();
	private $files = array();
	private $server = array();

	public function __construct() {
		$_GET = $this->clean($_GET);
		$_POST = $this->clean($_POST);
		$_REQUEST = $this->clean($_REQUEST);
		$_COOKIE = $this->clean($_COOKIE);
		$_FILES = $this->clean($_FILES);
		$_SERVER = $this->clean($_SERVER);

		//$this->get = $_GET;
		//$this->post = $_POST;
		$this->request = $_REQUEST;
		$this->cookie = $_COOKIE;
		$this->files = $_FILES;
		$this->server = $_SERVER;
		
		switch ($_SERVER['REQUEST_METHOD']){
			
			case 'GET':$this->get = $_GET;
			case 'POST':$this->get = $_GET;
			
		}
	}

	public function clean($data) {
		if (is_array($data)) {
			foreach ($data as $key => $value) {
				unset($data[$key]);

				$data[$this->clean($key)] = $this->clean($value);
			}
		} else {
			$data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8');
		}
		return $data;
	}
	
	public function getParam($param){
		return $this->get[$param];
	}
	
	public function getCookie($key){
		return $this->cookie[$key];
	}
	public function getFiles($key){
		return $this->files[$key];
	}
	public function getServer($key){
		return $this->server[$key];
	}
	
	public function hasParam($key){
		if(isset($this->get[$key])){
			return true;
		}
		return false;
	}
	public function hasCookie($key){
		if(isset($this->cookie[$key])){
			return true;
		}
		return false;
	}
	public function hasFiles($key){
		if(isset($this->files[$key])){
			return true;
		}
		return false;
	}
	public function hasServer($key){
		if(isset($this->server[$key])){
			return true;
		}
		return false;
	}
}